SET SERVEROUTPUT ON SIZE 1000000;
SET VERIFY OFF

DECLARE
	l_total_extracted	NUMBER;
	l_total_imported	NUMBER;
	l_total_extracted2	NUMBER;
	l_total_imported2	NUMBER;					
	l_func_id			VARCHAR2(100):='CAPFNDREC_DOC_SEQ';

BEGIN
	SELECT COUNT(1)
	INTO l_total_extracted        
	FROM	FND_DOCUMENT_SEQUENCES
	WHERE	Name			LIKE	UPPER('&1')||'%';
	
	SELECT COUNT(1) 
	INTO l_total_imported
	FROM CRST_FND_DOCUMENT_SEQ;
	
	SELECT COUNT(1)
	INTO l_total_extracted2        
	FROM
		FND_DOCUMENT_SEQUENCES			A,
		FND_DOC_SEQUENCE_ASSIGNMENTS	B
	WHERE	A.Doc_Sequence_ID	=	B.Doc_Sequence_ID
	AND		UPPER(A.Name)	LIKE	UPPER('&1')||'%';
	
	SELECT COUNT(1) 
	INTO l_total_imported2
	FROM CRST_FND_DOC_SEQ_ASSIGN;
	
	

	dbms_output.put_line('Function: '||l_func_id);		
	dbms_output.put_line('Total Extracted: '||TO_CHAR(l_total_extracted)) ;
	dbms_output.put_line('Total Imported:  '||TO_CHAR(l_total_imported));
	IF l_total_extracted <> l_total_imported THEN
		dbms_output.put_line('Error: No. of Records do not match!');
	END IF;		
						
EXCEPTION
	WHEN OTHERS THEN	
		dbms_output.put_line('Function Error: '||l_func_id);			
END;
/
